<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <p>{{ msg }}</p>
        <p>{{ msg2 }}</p>

        <button @click="msg='hello world'">修改msg</button>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: { // 普通属性
                msg: 'welcome to nanjing'
            },
            computed: { // 计算属性
                msg2: function(){
                    // 对普通属性进行处理，返回处理后的新数据
                    return this.msg.toUpperCase().split(' ').reverse().join(' ')
                }
            },
            watch: {
                msg: function(newValue, oldValue){
                    console.log('msg被修改了。。。。。', oldValue, newValue)
                }

            }
        })
    </script>
</body>
</html>